import { getToken, removeToken } from '@/utils/auth'
import router, { constantRoutes } from '@/router'

const getDefaultState = () => {
  return {
    token: getToken(),
    lockScreen: false,
    roles: [],
    userInfo: {},
  }
}

const state = getDefaultState()

const mutations = {
  RESET_STATE: (state) => {
    Object.assign(state, getDefaultState())
  },
  SET_TOKEN: (state, token) => {
    state.token = token
  },
  SET_ROLES: (state, roles) => {
    state.roles = roles
  },
  SET_USERINFO: (state, userInfo) => {
    state.userInfo = userInfo
  },
  SET_LOCK_SCREEN: (state, lockScreen) => {
    state.lockScreen = lockScreen
  }
}

export default {
  namespaced: true,
  state,
  mutations
}

